package com.youshang520i.demo.service.impl;

import com.youshang520i.demo.MyBean;
import com.youshang520i.demo.MyBean2;
import com.youshang520i.demo.service.HelloService;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * @author youshang
 * @date 2021/02/25 15:17
 **/
@Service
public class HelloServiceImpl implements HelloService, ApplicationContextAware {

    private ApplicationContext applicationContext;


    @Override
    public void hello() {
        System.out.println("hello !!!!!");
    }

//    @Autowired
//    private MyBean myBean1;
//    @Autowired
//    private MyBean2 myBean2;
//
//    @Override
//    public Object lite() {
//        MyBean bean = applicationContext.getBean(MyBean.class);
//        boolean equals = myBean1.equals(bean);
//        System.out.println(equals);
//        return myBean1;
//    }
//
//    @Override
//    public Object full() {
//        MyBean2 bean2 = applicationContext.getBean(MyBean2.class);
//        boolean equals = myBean2.equals(bean2);
//        System.out.println(equals);
//        return myBean2;
//    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
